package org.example;
import java.time.LocalDate;
import java.util.LinkedList;
public class YesterDate {
    public static String getPreviousDay(int year, int month, int day) {
        try {
            // 使用 LocalDate 获取前一天的日期
            LocalDate date = LocalDate.of(year, month, day);
            LocalDate previousDay = date.minusDays(1);
            return previousDay.toString();  // 返回ISO日期格式 "yyyy-MM-dd"
        } catch (Exception e) {
            return "Invalid Date"; // 如果日期无效，则返回错误信息
        }
    }

    public static void main(String[] args) {
        System.out.println(getPreviousDay(2025, 3, 10));  // 2025-03-09
        System.out.println(getPreviousDay(2025, 3, 1));   // 2025-02-28
        System.out.println(getPreviousDay(2025, 1, 1));   // 2024-12-31
    }
}
